<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
  </head>
  <body>
    <button id="get">GET请求</button>
    <button id="post">POST请求</button>
    <button id="delete">DELETE请求</button>
    <button id="jsonp">JSONP请求</button>
    <button id="nav">获取导航</button>
    <script>
      $('#nav').on('click', function () {
        $.ajax({
          type: 'GET',
          url: 'http:127.0.0.1/api/get_nav',
          
          success: (res) => {
            console.log(res)
          },
        })
      })
      $('#get').on('click', function () {
        $.ajax({
          type: 'GET',
          url: 'http:127.0.0.1/api/get',
          data: {
            name: 'lisa',
            age: 20,
          },
          success: (res) => {
            console.log(res)
          },
        })
      })
      $('#post').on('click', function () {
        $.ajax({
          type: 'POST',
          url: 'http:127.0.0.1/api/add',
          data: {
            name: 'IRIC',
            age: 20,
            gender:'boy'
          },
          success: (res) => {
            console.log(res)
          },
        })
      })

      $('#delete').on('click', function () {
        $.ajax({
          type: 'DELETE',
          url: 'http:127.0.0.1/api/delete',
          data: {
            name: 'IRIC',
            age: 20,
            gender:'boy'
          },
          success: (res) => {
            console.log(res)
          },
        })
      })
      $('#jsonp').on('click', function () {
        $.ajax({
          type: 'GET',
            url: 'http://127.0.0.1/api/jsonp',
            dataType: 'jsonp',
          success: (res) => {
            console.log(res)
          }
        })
      })
    </script>
  </body>
</html>
